package GIUmk2;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class MainPanel extends JPanel {

	/**
	 * Allows serialization.
	 */
	private static final long serialVersionUID = -5463654206148823511L;
	
	/**
	 * Burning penguins icon.
	 */
	private BufferedImage image;
	
	/**
	 * The parent frame for this panel.
	 */
	private FullFrame my_frame;
	
	/**
	 * Layout for flipping panels.
	 */
	private CardLayout my_layout;
	
	/**
	 * The string labels for the different content panels that will be available.
	 */
	protected static final String[] LAYOUT_LABELS = {
		"default", "login", "submitAuth", "submitRev",
		"submitRecc", "review", "edit", "assign", 
		"accept", "designate", "status", "viewAssign",
		"author", "reviewer", "subprog", "chair"
	};
	
	/**
	 * Constructor for building the parent panel.
	 * 
	 * @param the_frame the frame that the panel is attached to.
	 */
	public MainPanel(FullFrame the_frame) {
		super();
		my_frame = the_frame;
		my_layout = new CardLayout(0, 0);
		this.setLayout(my_layout);
		this.add(logoPanel(), LAYOUT_LABELS[0]);
		
		this.setVisible(true);		
	}
	
	protected void updateMainPanel(final String newPanel) {
		my_layout.show(this, newPanel);
	}
	
	private JPanel logoPanel() {
		JPanel design = factoryPanel();
		try {
			// this is mainly for comic relief.  If we do get an actual icon for this, replace reference here.
			image = ImageIO.read(new File("setFire.jpg"));
			JLabel bpIcon = new JLabel(new ImageIcon(image));
			design.setLayout(new BorderLayout());
			design.add(bpIcon);
		} catch (IOException e) {
			
		}
		design.setVisible(true);
		return design;
	}
	
	private JPanel loginPanel() {
		JPanel design = factoryPanel();
		
		return design;
	}
	
	private JPanel factoryPanel() {
		JPanel panel = new JPanel();
		panel.setBackground(Color.LIGHT_GRAY);
		panel.setPreferredSize(new Dimension(650, 600));
		return panel;
	}

}
